require(["jquery","bbcare",
    "scprit/followup/app/prematureOvarianFailure/lifeEventScale.servers.js",
    "scprit/followup/app/prematureOvarianFailure/prematureOvarianFailureDetail.ui.js",
    "scprit/followup/app/prematureOvarianFailure/lifeEventScale.event.js"],function($,$bb,$servers,$ui,$event){
    var getParams = $bb.getPageParams();
    $ui.basicInfoInit({"id":"#userInfo","data":getParams});//基本信息渲染：
    /*
    * 返回结果页
    * */
    var toBackResult= function(){
        var params = $(this).data("params");
        delete params.testTime;
        $bb.openPage("prematureOvarianFailureDetail",params);
    };
    var topbars = [
        {
            "icon":"fa fa-arrow-left",
            "name":"返回",
            "callback":toBackResult,
            "params":getParams
        }
    ];
    $bb.toolbar(topbars);

    var scoreObj = JSON.parse(getParams.score);

    var getQuestionsCallback = function(data){
        var questions = data.data["生活事件量表"];
        /*
        * 获取每一大项的初始题目序号：
        * */
        for(var i= 0;i<questions.length;i++){
            questions[i].initId = questions[i].questions[0].id;
        }
        $ui.questionsItemInit({"id":"#item-list","data":questions});//右侧列表：
        var totalQuestions  = $servers.dealQuestion(questions);
        var questions2 = $servers.dealQuestions_les(totalQuestions);
        $event.init(questions2,scoreObj,totalQuestions.length);

    };
    $servers.getQuestions(getParams, getQuestionsCallback);
});